<?php
/*
global $wpdb;

$custom_post_type = $GLOBALS['custom_post_type'];
$custom_taxonomy = $GLOBALS['custom_taxonomy'];
$custom_post_type_entries = array();
$custom_term_entries = array(); 
$html = '
<form method="post" action="' . $_SERVER['PHP_SELF'];' . ">
	<input type="text" name="name"><br>
	<input type="submit" name="submit" value="Submit Form"><br>
</form> ';
echo $html;
echo 'test';
exit;

// Select the id from all post with that custom posttype

$myrows = $wpdb->get_results( "SELECT id FROM wp_posts WHERE post_type = '$custom_post_type'" );

//add them to an array

for($i = 0; $i<count($myrows); $i++) {
	$custom_post_type_entries[] = $myrows[$i]->id;
}

// delete all post with that posttype

function delete_post_type () {
	for ($i = 0; $i<count($custom_post_type_entries); $i++) {
		$wpdb->query("
			DELETE
			FROM wp_posts
			INNER JOIN wp_postmeta ON wp_postmeta.post_id = $custom_post_type_entries[$i] 
			WHERE wp_posts.id = $custom_post_type_entries[$i]
	        OR wp_posts.post_parent = $custom_post_type_entries[$i]
		");
	}
}

wp_reset_query();

// select all term_id with that custom taxonomy

$myrows = $wpdb->get_results( "SELECT term_id FROM wp_term_taxonomy WHERE taxonomy = '$custom_taxonomy'" );

wp_reset_query();

//add them to an array

for($i = 0; $i<count($myrows); $i++) {
	$custom_term_entries[] = $myrows[$i]->term_id;
}

// delete all post with that custom taxonomy
function delete_custom_taxonomy() {	
	for ($i = 0; $i<count($custom_term_entries); $i++) {
		$wpdb->query("
			DELETE
			FROM wp_terms
			INNER JOIN wp_terms ON wp_terms.term_id = $custom_term_entries[$i]
			WHERE wp_term_taxonomy.term_id = $custom_term_entries[$i]
			AND wp_term_taxonomy.taxonomy = '$custom_taxonomy'
		");
	}
}